<?php
/**
 * ===============================================
 * 版权所有 2019-2050 青岛铁锤科技有限公司，并保留所有权利。
 * 网站地址: http://www.huaxianling.com
 * ===============================================
 * Author: Happy dong
 * Created Time: 2019-11-29 14:24
 *
 * Version: 2.0
 */

namespace App\Modules\Inventory\Repositories;


use App\Models\GoodsOrderItem;
use Flower\Core\Repository\Eloquent\BaseRepository;

class GoodsOrderItemsRepository extends BaseRepository
{
	public function model()
	{
		return GoodsOrderItem::class;
	}

	public function addItem($orderId, $params)
	{
		$data = array_map(function ($v) use ($orderId) {
			return [
				'order_id'   => $orderId,
				'goods_id'   => $v['goods_id'],
				'goods_name' => $v['goods_name'],
				'price'      => $v['market_price'],
				'real_price' => $v['market_price'],
				'count'      => $v['count'],
				'created_at' => date('Y-m-d H:i:s')
			];
		}, $params);
		return $this->model->insert($data);
	}
}